package com.cdn.log.mq;

import com.cdn.log.consts.CLogConst;
import org.slf4j.MDC;

import java.util.function.Consumer;

/**
 * @author 蔡定努
 *  2024/06/03 11:05
 */
public class ClogMqConsumerProcess {


    /**
     * @param cdnMssage 消息体封装类
     * @param consumer 具体逻辑
     * @author 蔡定努
     */
    public static void run(ClogMessage cdnMssage, Consumer consumer){
        try{
            MDC.put(CLogConst.TRACE_ID, cdnMssage.getTraceId());
            consumer.accept(cdnMssage.getT());
        }finally {
           MDC.remove(CLogConst.TRACE_ID);
        }
    }
}
